# -*- coding: utf-8 -*-
"""
Created on Thu Oct 29 12:47:47 2020

@author: L1OML01
Link to source code: https://github.com/ganong-noel/ui_calculator

"""

# Set working directory
import os 
os.chdir("S:/RobV/UI-inequality")

# Source in helper packages
import pandas as pd
import sys
sys.path.insert(0, "source")

# Source in UI calculator function
from ui_calculator import calc_weekly_state_quarterly

# Read in CPS data
income_data = pd.read_csv("Data/UIpy_input.csv")

# Calculate UI benefits
income_data['UI'] = calc_weekly_state_quarterly(
        income_data['q1'],                      
        income_data['q2'],
        income_data['q3'],
        income_data['q4'],
        income_data['st'],
        income_data['wkswork'])

# Add extra UI benefits under CARES 
income_data['UI_CARES'] = income_data['UI'] + 600

# Export data
income_data.to_stata("Data/UIpy_output.dta") 

print("FINISHED")